import org.jetbrains.annotations.NotNull;

import java.util.regex.Pattern;

public class IdToKeyword {
    public static void main(String[] args) {
        String[] ids = new String[]{
                "level_rune_09-01", "level_rune_09-02",
                "level_crisis_v2_01-07", "crisis_v2_season_1_1",
                "a001_01_perm", "a001_ex05",
                "act11d0_ex08#f#", "act11d0_s02",
                "act11mini_03#f#", "act11mini_04"
        };

        for (String id : ids) {
            System.out.println(getIdKeyInfo(id));
        }
    }

    private static final Pattern NOT_ID_KEY_INFO = Pattern.compile(
            // level_、season_、前导零、以-或者_划分的最后一个后缀
            "level_|season_|(?<!\\d)0+(?=\\d)|[-_]+[^-_]+($|_+perm$)"
    );

    @NotNull
    private static String getIdKeyInfo(String id) {
        // 去除所有非关键信息
        return NOT_ID_KEY_INFO.matcher(id).replaceAll("");
    }

}
